home *** CD-ROM | disk | FTP | other *** search
/ How Many Bugs in a Box / How Many Bugs in a Box.cdr / bugs / act3 / 00270_bugchoose.ls < prev    next >
Encoding:
Text File  |  1995-03-28  |  4.6 KB  |  160 lines

  1. on bugchoose
  2.   global lev, nlist, game3level, bugnumber, buglist
  3.   repeat with xxx = 5 to 34
  4.     puppetSprite(xxx, 0)
  5.     set the visible of sprite xxx to 0
  6.   end repeat
  7.   updateStage()
  8.   set many to game3level * 2
  9.   if game3level = 1 then
  10.     set bugnumber to [10]
  11.     set most to 5
  12.     set mgroup to 1
  13.   else
  14.     if game3level = 2 then
  15.       set bugnumber to [20]
  16.       set most to 5
  17.       set mgroup to 0
  18.     else
  19.       set bugnumber to [28]
  20.       set most to 10
  21.       set mgroup to 0
  22.     end if
  23.   end if
  24.   repeat with xxx = 1 to many + 2
  25.     set disgrunt to getAt(bugnumber, 1)
  26.     set yib to random(disgrunt - (3 + many - xxx))
  27.     if yib > most then
  28.       set yib to random(most)
  29.     end if
  30.     add(bugnumber, yib)
  31.     setAt(bugnumber, 1, disgrunt - yib)
  32.   end repeat
  33.   repeat with xxx = 1 to many + 1
  34.     set disgrunt to getAt(bugnumber, xxx)
  35.     if disgrunt > most then
  36.       set diff to disgrunt - most
  37.       set disgrunt to most
  38.       setAt(bugnumber, xxx, disgrunt)
  39.       setAt(bugnumber, xxx + 1, getAt(bugnumber, xxx + 1) + diff)
  40.     end if
  41.   end repeat
  42.   put bugnumber
  43.   repeat with xxx = 1 to many - 1
  44.     repeat with slumlord = xxx + 1 to many
  45.       if getAt(bugnumber, xxx) < getAt(bugnumber, slumlord) then
  46.         set trex to getAt(bugnumber, slumlord)
  47.         setAt(bugnumber, slumlord, getAt(bugnumber, xxx))
  48.         setAt(bugnumber, xxx, trex)
  49.       end if
  50.     end repeat
  51.   end repeat
  52.   repeat with xxx = 1 to many
  53.     set slumlord to random(many)
  54.     set trex to getAt(bugnumber, slumlord)
  55.     setAt(bugnumber, slumlord, getAt(bugnumber, xxx))
  56.     setAt(bugnumber, xxx, trex)
  57.   end repeat
  58.   set templist to [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
  59.   set buglist to []
  60.   repeat with xxx = 1 to count(bugnumber)
  61.     set slumlord to random(count(templist))
  62.     add(buglist, getAt(templist, slumlord))
  63.     deleteAt(templist, slumlord)
  64.   end repeat
  65.   set buggrid to []
  66.   repeat with xxx = 1 to 8
  67.     add(buggrid, [0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
  68.   end repeat
  69.   if game3level < 3 then
  70.     set buggrid to [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]
  71.   end if
  72.   set bugstart to the number of cast "bug1" - 1
  73.   set channel to 5
  74.   repeat with xxx = 1 to count(bugnumber)
  75.     set tempx to random(8) + 1
  76.     set tempy to random(5) + 1
  77.     repeat with yyy = 1 to getAt(bugnumber, xxx)
  78.       set spriteinfo to []
  79.       add(spriteinfo, getAt(buglist, xxx) + bugstart)
  80.       if mgroup = 1 then
  81.         set tempx to tempx + random(3) - 2
  82.         set tempy to tempy + random(3) - 2
  83.         if (tempx < 1) or (tempx > 10) then
  84.           set tempx to random(10)
  85.         end if
  86.         if (tempy < 1) or (tempy > 7) then
  87.           set tempy to random(7)
  88.         end if
  89.       else
  90.         set tempx to random(10)
  91.         set tempy to random(7)
  92.       end if
  93.       repeat while getAt(getAt(buggrid, tempy), tempx) <> 0
  94.         if mgroup = 1 then
  95.           set tempx to tempx + random(3) - 2
  96.           set tempy to tempy + random(3) - 2
  97.           if (tempx < 1) or (tempx > 10) then
  98.             set tempx to random(10)
  99.           end if
  100.           if (tempy < 1) or (tempy > 7) then
  101.             set tempy to random(7)
  102.           end if
  103.           next repeat
  104.         end if
  105.         set tempx to random(10)
  106.         set tempy to random(7)
  107.       end repeat
  108.       setAt(getAt(buggrid, tempy), tempx, 1)
  109.       add(spriteinfo, (tempx * 64) - 32)
  110.       add(spriteinfo, (tempy * 50) - 25)
  111.       add(spriteinfo, 1)
  112.       sactivate(channel, spriteinfo)
  113.       set channel to channel + 1
  114.     end repeat
  115.   end repeat
  116.   updateStage()
  117. end
  118.  
  119. on dohint
  120.   global TRIAL, game3level, tesla
  121.   set TRIAL to TRIAL + 1
  122.   if TRIAL = 1 then
  123.     givehint("bag3.0")
  124.   else
  125.     if TRIAL = 2 then
  126.       givehint("bag3.1")
  127.       hibugall()
  128.     else
  129.       givehint("bag3.2")
  130.       flashanswer()
  131.       givehint("bag3.3")
  132.     end if
  133.   end if
  134.   go("levela" & game3level)
  135. end
  136.  
  137. on sactivate schan, slist
  138.   if schan < 48 then
  139.     if listp(slist) then
  140.       puppetSprite(schan, 1)
  141.       set the type of sprite schan to getAt(slist, 4)
  142.       set the castNum of sprite schan to getAt(slist, 1)
  143.       set the locH of sprite schan to getAt(slist, 2)
  144.       set the locV of sprite schan to getAt(slist, 3)
  145.       set the foreColor of sprite schan to 255
  146.       set the ink of sprite schan to 36
  147.       set the stretch of sprite schan to 0
  148.       set the visible of sprite schan to 1
  149.     end if
  150.   end if
  151. end
  152.  
  153. on sinfo schan
  154.   set dumdyo to []
  155.   add(dumdyo, the castNum of sprite schan)
  156.   add(dumdyo, the locH of sprite schan)
  157.   add(dumdyo, the locV of sprite schan)
  158.   add(dumdyo, the type of sprite schan)
  159. end
  160.